package com.briup.smartlabs.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.briup.smartlabs.bean.ex.Device;
import com.briup.smartlabs.common.utils.Response;
import com.briup.smartlabs.service.SmartDeviceService;
import com.briup.smartlabs.web.vm.CommandVM;
import com.github.pagehelper.PageInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(tags = "设备服务")
@RestController
@RequestMapping("/device")
public class DeviceController {
	@Autowired
	private SmartDeviceService deviceService;

	@GetMapping("/by/condition")
	public Response<PageInfo<Device>> findByCondition(
			int pageNum,
			int pageSize,
			String typeId,String key){
		
		return Response.ok(null);
	}
	
	@ApiOperation(value = "发送指令，控制设备运行")
	@PostMapping("/sendCommand")
	public Response<String> sendCommand(CommandVM command){
		deviceService.sendMessage(command.toString());
		return Response.ok("操作成功！");
	}
}






